package com.cyx.reggie.controller;

/**
 * @author 陈彦西
 * @date 2024/7/20 下午3:55
 */

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cyx.reggie.common.R;
import com.cyx.reggie.entity.OrderDetail;
import com.cyx.reggie.service.OrderDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 订单明细
 */
@Slf4j
@RestController
@RequestMapping("/orderDetail")
public class OrderDetailController {

    @Autowired
    private OrderDetailService orderDetailService;

    /**
     * 根据id查询订单中的菜品
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public R<List<OrderDetail>> listById(@PathVariable String id) {
        LambdaQueryWrapper<OrderDetail> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(OrderDetail::getOrderId, id);
        List<OrderDetail> list = orderDetailService.list(queryWrapper);

        return R.success(list);
    }


}
